<template>
	<el-form label-width="130px" :model="form" :rules="rules" ref="queryForm">
		<el-row>
			<el-col :span="12">
				
				<el-form-item label="行政区域" prop="district">
					<el-select v-model="form.district" size="default" placeholder="请选择" style="width:190px" clearable
						filterable>
						<el-option v-for="item in options" :key="item.dictValue" :label="item.dictLabel"
							:value="item.dictValue" />
					</el-select>
				</el-form-item>


				<el-form-item label="机动指挥所名称" prop="name">
					<el-input v-model="form.name" style="width: 190px;"></el-input>

				</el-form-item>

				<el-form-item label="所属指挥部" prop="headCode">
					<el-select v-model="form.headCode" size="default" placeholder="请选择" style="width: 190px" clearable
						filterable>
						<el-option v-for="item in zhbOptions" :key="item.dictValue" :label="item.dictLabel"
							:value="item.dictValue" />
					</el-select>
				</el-form-item>

				<el-form-item label="通信车数量" prop="communicationVanNumber">
					<el-input v-model="form.communicationVanNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'communicationVanNumber', 0)"></el-input>
				</el-form-item>

				<el-form-item label="保障车辆数量" prop="safeguardCarNumber">
					<el-input v-model="form.safeguardCarNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'safeguardCarNumber', 0)"></el-input>
				</el-form-item>


				<el-form-item label="承载保障人员数量" prop="carrySafeguardNumber">
					<el-input v-model="form.carrySafeguardNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'carrySafeguardNumber', 0)"></el-input>
				</el-form-item>

				<el-form-item label="连接通信网络" prop="communicationNetwork">
					<el-input v-model="form.communicationNetwork" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="竣工日期" prop="completedTime">
					<el-date-picker v-model="form.completedTime" type="date" size="default" format="YYYY-MM-DD"
						value-format="YYYY-MM-DD" style="width: 190px;" />
				</el-form-item>

				<el-form-item label="管理单位" prop="managementUnit">
					<el-input v-model="form.managementUnit" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="联系电话" prop="contactNumber">
					<el-input v-model="form.contactNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'contactNumber', 0)" maxlength="11"></el-input>
				</el-form-item>

				




			</el-col>
			<el-col :span="12">

				<el-form-item label="机动指挥所简称" prop="shortName">
					<el-input v-model="form.shortName" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="功能描述" prop="functionDes">
					<el-input v-model="form.functionDes" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="指挥车辆数量" prop="commandVehicleNumber">
					<el-input v-model="form.commandVehicleNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'commandVehicleNumber', 0)"></el-input>
				</el-form-item>

				<el-form-item label="信息采集车数量" prop="informationCarNumber">
					<el-input v-model="form.informationCarNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'informationCarNumber', 0)"></el-input>
				</el-form-item>

				<el-form-item label="承载指挥人员数量" prop="carryCommandNumber">
					<el-input v-model="form.carryCommandNumber" style="width: 190px;"
						@input="e => regOnlyNumSpot(e, form, 'carryCommandNumber', 0)"></el-input>
				</el-form-item>


				<el-form-item label="指挥控制手段" prop="comControl">
					<el-input v-model="form.comControl" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="批准文号" prop="approval">
					<el-input v-model="form.approval" style="width: 190px;"></el-input>
				</el-form-item>

				<el-form-item label="开工日期" prop="commenceTime">
					<el-date-picker v-model="form.commenceTime" type="date" size="default" format="YYYY-MM-DD"
						value-format="YYYY-MM-DD" style="width: 190px;" />
				</el-form-item>

				<el-form-item label="建设单位" prop="constructionUnit">
					<el-input v-model="form.constructionUnit" style="width: 190px;"></el-input>
				</el-form-item>
				
				<el-form-item label="联系人" prop="contact">
					<el-input v-model="form.contact" style="width: 190px;"></el-input>
				</el-form-item>


			</el-col>
		</el-row>

		<div style="display: flex;justify-content: flex-end;">
			<el-button @click="closethis()" @keyup.prevent @keydown.enter.prevent>取消</el-button>
			<el-button type="primary" @click="submit(queryForm)" @keyup.prevent @keydown.enter.prevent>确定</el-button>
		</div>
	</el-form>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue'
	import {
		ElMessage
	} from 'element-plus'

	import {
		commonInterface
	} from '@/api/common/common'

	import {
		regOnlyNumSpot
	} from '@/utils/reg'

	const emit = defineEmits(['getList', 'closeWindow'])
	const props = defineProps(['editData', 'zhbOptions','options'])

	const form = ref({})

	const queryForm = ref('')

	const zhbOptions = ref()
	const options = ref()



	//必填项
	const rules = reactive({

		name: [{
			required: true,
			message: "此选项不能为空!",
			trigger: "blur"
		}],
		cpType: [{
			required: true,
			message: "此选项不能为空!",
			trigger: "change"
		}],
		headCode: [{
			required: true,
			message: "此选项不能为空!",
			trigger: "change"
		}],
		district:[{
			required: true,
			message: "此选项不能为空!",
			trigger: "change"
		}]


	})
	//取消
	const closethis = () => {
		emit('closeWindow')
	}

	//确定
	const submit = async (e) => {
		if (!e) return
		await e.validate((valid) => {
			if (valid) {
				let method = 'post'
				if (props.editData) method = 'put'
				commonInterface('/back/renfang/zhtx/flexible/', form.value, method).then(result => {
					if (result.code === 200) {
						ElMessage.success(result.msg)
						emit('closeWindow')
						emit('getList')
					} else {
						ElMessage.error(result.msg)
					}
				})
			}
		})
	}

	onMounted(() => {
		zhbOptions.value = props.zhbOptions
		options.value = props.options
		// zhstypeOptions.value = props.zhstypeOptions
		// fcgswqdjOptions.value = props.fcgswqdjOptions
		// fhwqdjOptions.value = props.fhwqdjOptions
		// fhjbOptions.value = props.fhjbOptions
		// gcwcqkOptions.value = props.gcwcqkOptions
		// gcjqqkOptions.value = props.gcjqqkOptions
		if (props.editData) form.value = props.editData
	})
</script>

<style>
</style>